<#include "/common/head3.html"/> 
新增页面
<div data-options="region:'center',title:'',split:false,border:false" style="height:30px;">
	<table id="dg"></table>
</div>
<div id="tb" data-options="region:'north',title:'',split:false,border:false" style="height:30px;">
	 <input type="hidden" id="activityid" name="activityid" value="${activityid!''}"></input>
			        		<span class="search_item">
				            	<span class="item_text">搜索商品名: </span>
				            	<span class="item_obj">
				            		<input class="easyui-textbox" type="text" name="goodsname" value=""/>
				            	</span>    
				            </span>
				            <span class="search_item">
				            	<span class="item_text">搜索商品ID: </span>
				            	<span class="item_obj">
				            		<input class="easyui-textbox" type="text" name="productid" value=""/>
				            	</span>    
				            </span>
				            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="glyphicon-search" onclick="zcurdSearch(this)">搜索</a>
</div> 
<div data-options="region:'south',title:'',split:false,border:false" style="height:300px;" class="easyui-panel addPage">
		<form class="easyui-form" id="ff" method="post" data-options="novalidate:true">
			<table>
				<tr>
					<td id="qwe1">
						<span class="adertisement">已选择商品: </span>
						<input readonly="readonly" class="easyui-textbox" type="text" id="goodsname1" name="goodsname1" value="" />
					</td>	
					<input type="hidden" id="activityid" name="activityid" value="${activityid!''}"></input>
				</tr>
				<tr>
					<td id="qwe2">
						<span class="adertisement">名称: </span>
						<input class="easyui-textbox" type="text" id="goodsname" name="goodsname" value="" />
					</td>
					<td id="qwe3">
						<input type="hidden" id="productid" name="productid" value=""></input>			
					</td> 
				</tr>
				<tr>
					<td>
						<span class="search_item">
						  <span class="adertisement">状态: </span>
						  <span class="item_obj">
						        <input class="easyui-combobox" name="adstate" id="adstate" style="width:100px" data-options="
						           			valueField: 'id',
						    				textField: 'text',
						    				panelHeight:'auto',
						    				editable:false,
						           			data: [
						           				{id:'1', text:'禁用',selected:'true'}
							            		,{id:'0', text:'启用'}
						           			]
						           	" />
					 </span>
					</td>
					<td>
						<span class="adertisement">文字说明: </span>
						<input required="required" class="easyui-textbox" type="text" id="goodsdesc" name="goodsdesc" value="" />
					</td>
				</tr>
				<tr>
					<td>
					<div data-options="region:'south',border:false" style="text-align: right; padding: 12px; border-top-width: 0px; border-top-style: solid; border-top-color: rgb(221, 221, 221); width: 674px; height: 28px;" title="" class="panel-body panel-body-noheader panel-body-noborder layout-body">
		            <a class="easyui-linkbutton color1 l-btn l-btn-small" href="javascript:void(0)" onclick="javascript:save();" style="width: 220px;" group="" id="">
		            	<span class="l-btn-center" style="margin-top: 0px;"><span class="l-btn-text">保存</span></span>
		            </a>
		            </td>
				</tr>
			</table>
		</form>
</div> 

<script type="text/javascript">
//var aa = $("#activityid").val();
var datagrid = $("#dg");
var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
    	striped:true,
        rownumbers:true,
    	url:'listDataInfoo1',
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 10,
    	pagination:true,
    	multiSort:true,
    	singleSelect:true,
//         queryParams: getInitParam(),
        columns: [[
				{field:'productid',title: '商品ID', width:80}
				,{field:'goodsname', title:'名称', width:100}
				,{field:'mername', title: '供货商', width:80}
				,{field:'paytype', title: '支付方式', width:113,formatter:formatpaytype}
				,{field:'categoryname', title: '商品分类', width:113}
				,{field:'real_amount_yuan', title: '商品价格', width:113}
	           	,{field:'state', title: '上下架', width:80,formatter:formatstate}
	           	,{field:'adstate', title: '状态', width:80,hidden:'true'}
	           	,{field:'description', title: '广告说明', width:80,hidden:'true'}
	           ]],
	    onClickRow:function(rowIndex, rowData){
	    	var a = rowData.goodsname;
	    	var b = rowData.productid;
	    	$("#qwe1 input[type='text']").val(a);
	    	$("#qwe2 input[type='text']").val(a);
	    	$("#qwe3 input[type='hidden']").val(b);
	    }
	};
$(function() {
	datagrid.datagrid(dgOptions);
}); 

function formatpaytype(value,row,index){
	if (value == "comb") {
		return "固定积分+现金";
	}else if(value == "cust"){
		return "任意积分";
	}else if (value == "points") {
		return "全积分";
	}else if (value == "cash") {
		return "现金";
	}
	
}

function formatstate(value,row,index){
	if(value == 0){
		return "下架";
	}else if(value == 1){
		return "上架";
	}
}

function save() {
	var a = $("#goodsname").val();
	var b = $("#productid").val();
	$("#ff").form('submit', { 
        url: "addInfo", 
        onSubmit: function () {   
        	//表单提交前的回调函数 
        	if(!$("#ff").form('enableValidation').form('validate')) {
            	$.messager.alert('操作结果','请检查标红输入项','error');
        		return false;
        	}       	
        	
        }, 
        success: function (v) {
        	var v = eval('('+v+')');
        	var result = v.result;
        	var a = $("#activityid").val();
        	if(result =='success'){
    	        	$.messager.alert('操作结果','添加成功！','info',function(){location.replace('adcurationPage?activityid='+a)});
        	}else{
    	        	$.messager.alert('操作结果','编码不唯一','error');
        	}
    	} 
      }); 
}

function update() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var activityid = rowsSel[0].activityid;
	location.replace('updatePage?activityid='+activityid);
}


function zcurdSearch() {
	var param = zcurdGetParam();
		datagrid.datagrid("load", param);
}

function zcurdGetParam() {
	var param = {};
	$("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param[$(item).attr("name")] = $(item).val().trim();	
		}
	});
	return param;
}

</script>
<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>